package com.djhu.freepartner.core.exception;

import com.djhu.freepartner.core.RestRsp;
import com.djhu.freepartner.core.Status;

/**
 * 服务异常
 * @author KevinBlandy
 *
 */
public class ServiceException extends Exception{

	/**
	 * 
	 */
	private static final long serialVersionUID = -2804390381900229831L;
	
	private RestRsp restRsp;
	
	public ServiceException() {
		
	}
	
	public ServiceException(String message) {
		this(message,Status.BAD_REQUEST.getCode());
	}
	
	public ServiceException(Status status) {
		this(status.getDesc(),status.getCode());
	}
	
	public ServiceException(String message, int code) {
		super(message);
		this.restRsp = new RestRsp();
		restRsp.setMsg(message);
		restRsp.setCode(code);
		//this.message.setSuccess(Boolean.FALSE);
	}
	
	public RestRsp getErrorMessage(){
		return this.restRsp;
	}
}
